package com.qunar.wan.common_api.service;

import org.apache.lucene.document.Document;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.Query;

/**
 * Created by hiCyoung on 13-11-30.
 */
public interface ConvertService<T, K> {

    /**
     * 将单个对象转化成对应的Document
     *
     * @param t
     * @return
     */
    Document convert2Doc(T t);

    /**
     * 将Document对象转换成对应的Lucene IndexObj，并根据Query对相应字段高亮
     *
     * @param document
     * @param query
     * @return
     */
    K convert2IndexObj(Document document, Query query);

    /**
     * 设置更新的Term标识
     *
     * @param t
     * @return
     */
    Term updateIndexTerm(T t);

}
